<template>
  <div class="text-tooltip-container">
    <span class="text-tooltip-text" @mouseover="showTooltip" @mouseleave="hideTooltip">
      <slot name="txto"></slot>
    </span>
    <!--  -->
    <div v-if="isVisible" class="text-tooltip-content">
      {{ tooltipText }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'TextTooltip',
  props: {
   
    tooltipText: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      isVisible: false
    };
  },
  methods: {
    showTooltip() {
      this.isVisible = true;
    },
    hideTooltip() {
      this.isVisible = false;
    }
  }
};
</script>

<style scoped>
.text-tooltip-container {

  position: relative;
  display: inline-block;
}

.text-tooltip-text {
  cursor: pointer;
}

.text-tooltip-content {
  visibility: hidden;
  width: 65px;
  height: 42px;
  text-align: center;
  line-height: 42px;
  font-size: 14px;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 5px;
  position: absolute;
  z-index: 1;
  bottom: 0;
  /* 调整位置以适应你的设计 */
  left: 55px;
  /* margin-left: -60px; */
  opacity: 1;
  transition: opacity 0.3s;
}

.text-tooltip-content::before {
  content: '';
  position: absolute;
  bottom: 15px;
  /* 调整位置以适应你的设计 */
  left: -8px;
  transform: translateX(-50%);
  border-width: 8px;
  border-style: solid;
  border-color: transparent rgba(0, 0, 0, 0.75) transparent transparent;
}

.text-tooltip-container:hover .text-tooltip-content {
  visibility: visible;
  opacity: 1;
}</style>
